import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { PrismaModule } from './prisma/prisma.module';

import { ConfigModule } from '@nestjs/config';
import { AuthModule } from './auth/auth.module';
import { CodeModule } from './code/code.module';
import { JwtStrategy } from './jwt/jwt.strategy';
import { ChangeUserAvatarModule } from './change-user-avatar/change-user-avatar.module';
import { ChangeuserModule } from './changeuser/changeuser.module';
import { ProjectModule } from './project/project.module';
import { DirectoryModule } from './directory/directory.module';
import { InterfacesModule } from './interfaces/interfaces.module';
//导入swiger所需依赖
import { NestFactory } from '@nestjs/core';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';

@Module({
  imports: [
    PrismaModule,

    ConfigModule.forRoot({
      isGlobal: true,
    }),

    AuthModule,

    CodeModule,

    ChangeUserAvatarModule,

    ChangeuserModule,

    ProjectModule,

    DirectoryModule,

    InterfacesModule,
  ],
  controllers: [AppController],
  providers: [AppService, JwtStrategy],
})
export class AppModule {}

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  // 创建 Swagger 文档配置
  const config = new DocumentBuilder()
    .setTitle('云漫API')
    .setDescription('欢迎来到云漫API')
    .setVersion('1.0')
    .addTag('api')
    .addBearerAuth()
    .build();

  const document = SwaggerModule.createDocument(app, config);
  SwaggerModule.setup('api', app, document);

  await app.listen(3001);
}

bootstrap();
